﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PBDesk.Framework.WebUI;
using System.Text;

namespace PBDesk.Web.Main.UI.Controls.Rambling
{
    public partial class TopMenu : PBDesk.Framework.WebUI.BaseUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            StringBuilder sb = new StringBuilder();
            CreateTopMenuTab(ref sb, "Home", "/");
            if (!Request.IsAuthenticated)
            {
                CreateTopMenuTab(ref sb, "Login", "/UI/Gen/LoginHelp.aspx");
            }
            CreateTopMenuTab(ref sb, "Tech News & Articles", "/UI/Art/Default.aspx");
            //CreateTopMenuTab(ref sb, "Learning Center", "/");
            //CreateTopMenuTab(ref sb, "Assessment Center", "/");
            CreateTopMenuTab(ref sb, "My Projects", "/UI/Projs/Default.aspx");
            CreateTopMenuTab(ref sb, "Tools & Utils", "/UI/TU/Default.aspx");
            CreateTopMenuTab(ref sb, "Blogs", "/UI/Blogs/Default.aspx");
            CreateTopMenuTab(ref sb, "About Me", "/UI/Gen/AboutMe.aspx");            

            topnavDivUl.InnerHtml = sb.ToString();
 
        }

        private void CreateTopMenuTab(ref StringBuilder sb, string tabName, string url)
        {
            string liFormat = "<li {0}><a href=\"{1}\">{2}</a></li>";
            string activeTabClass = "class=\"active\"";
            BasePage page = (BasePage)this.Page;
            if (page.ActiveTab == tabName)
                sb.AppendFormat(liFormat, activeTabClass, url, tabName);
            else
                sb.AppendFormat(liFormat, string.Empty, url, tabName);
        }
    }
}